<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/layui.css}"  media="all" />
    <link rel="stylesheet" th:href="@{/css/daohang.css}" />
    <script th:src="@{/layui/layui.all.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/jquery-3.2.1.js}"></script>
    <link rel="stylesheet" th:href="@{/css/main.css}" />

</head>
<body bgcolor="">
<!--轮播图片-->
<div class="layui-carousel" id="test3">
    <div carousel-item="">
        <div><img src="image/lun.jpg" width="100%" height="100%"/></div>
        <div><img src="image/lun2.jpg" width="100%" height="100%"/></div>
        <div><img src="image/13.jpg" width="100%" height="120%"/></div>
    </div>
</div>
<script>
    layui.use('carousel', function () {
    var carousel = layui.carousel;
    //建造实例
    carousel.render({
        elem: '#test3'
        , width: '100%' //设置容器宽度
        , arrow: 'none' //始终显示箭头
        , width: '1080px'
        , height: '150px'
        //,anim: 'updown' //切换动画方式
    });
});
</script>
<fieldset class="layui-elem-field layui-field-title" >
    <legend><span class="" style="font-size: 14px">
  <a href="">投票<span class="layui-box">&gt;</span></a>
  <a href="" >报名投票<span class="layui-box">&gt;</span></a>
</span>
    </legend>
</fieldset>
<input id="isOut" type="text" th:value="${you}" hidden="hidden" />

<div class="bo">
<form class="layui-form" action="/dor/VC" method="post" style="width:80%;">
    <input type="text" name="img" id="tupian" hidden="hidden"/>


    <div class="layui-form-item">
        <label class="layui-form-label">投票主题</label>
        <div class="layui-input-inline" >
            <input type="text" class="layui-input" name="topic" id="topic" disabled="disabled"/>
            <input type="text" class="layui-input" name="topicId" id="topicId"   style="display:none" disabled="disabled" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">参与寝室号</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="roomId" disabled="disabled" th:value="${session.user.getRoom_id()}"/>
            <input type="text" class="layui-input" name="roomId"  th:value="${session.user.getRoom_id()}" style="display:none"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">寝室描述</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入寝室描述" class="layui-textarea linksDesc" name="descript"></textarea>
        </div>
    </div>

    <div class="layui-upload">
        <button type="button" class="layui-btn" id="test1">上传图片</button>
        <div class="layui-upload-list">
            <img style="width:180px; height:auto; " class="layui-upload-img" id="demo1"/>
            <p id="demoText"></p>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="addLinks">提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</div>


<script>
//    $(w).show();
    $('button[type="reset"]').click()
    layui.use('upload', function() {
        var $ = layui.jquery
            , upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: '/dor/upload'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                    //console.log(result);

                    $('#tupian').val(result);
                });
            }
            , done: function (res) {
                /*//如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功*/
            }
            , error: function () {

            }
        });

    })
</script>
<script>
    $(function () {
        $.get('/dor/VTZ', function (data) {
            console.log(data);
            $('#topic').val(data.title);
            $('#topicId').val(data.id);


        })
    })



</script>
<script th:inline="javascript">
    var flag = [[${flag}]];
    if (flag === 1){
        layer.open({
            content: '报名成功'
        });
    }else if(flag === 0){
        layer.msg('你的寝室不满足此次评选条件（积分不足）')
    }

    var ok = false;
    $.get('/dor/isStart', function (date) {
        ok = date;
        if (ok) {
            // TODO alert("有")
        }
    });

    //提示报名提示
    var you = $('#isOut').val();
    if (you == 'true') {
      /*  var height = $(document).height();
        $('.out_bg').css('height', height);
        $('.out_bg').show();*/
//        $('#msg').show();
        /*l*/

        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title: '提示'
                ,content: '您的寝室已经报过名了'
                ,closeBtn: 0
                ,btn: ['前往投票']
                ,yes: function(index, layero){
                    window.location.replace('/dor/vote');
                }
            });

        });
    }

    $.get('/dor/HVC', function (data) {
        if (!data) {
            //弹窗提示报名条件
            layui.use('layer', function(){
                var layer = layui.layer;
                layer.open({
                    title: '报名须知'
                    ,content: '<span>&nbsp;1.报名条件：寝室积分需要在110分以上。</span>' +
                    '<br/><span>&nbsp;2.为防止不正当刷票，每个学生只能投一票。</span>' +
                    '<br/><span>&nbsp;3.投票开始后，寝室的排列顺序为票数由高到低降序排列。</span>' +
                    '<br/><span>&nbsp;4.投票截止时，学院将根据投票情况选出几个获奖寝室。</span>'
                    ,closeBtn: 0
                    ,maxWidth: 400
                });

            });
        }
    })



</script>


</body>
</html>